<?php echo $this->render($this->includeDir . '/toolbar.php');?>
<?php echo $this->flashMessage();?>
<?php 
	$arrParam = $this->arrParam;
	$this->Item['name'] = Zendvn_Filter_Filter::filterContent($this->Item['name']);
	$name 			= $this->formText('name',$this->Item['name'],array('class'=>'width-300 bg-green2 floatLeft' ));
	$email 			= $this->formText('email',$this->Item['email'],array('class'=>'width-300 floatLeft' ));
	$phone 			= $this->formText('phone',$this->Item['phone'],array('class'=>'width-300 floatLeft' ));
	
		

	$options 		= array('active'=>$this->translate('Kích hoạt'), 'inactive'=>$this->translate('Ẩn'));	
	$status 		= $this->formSelect('status',$this->Item['status'],array('class'=>'width-150'),$options);
	
	$content	 	= $this->formTextarea('content', Zendvn_Filter_Filter::filterContent($this->Item['content']), array('class' => 'width-400 bg-green2 floatLeft','rows'=>8));
	
	
	$picture	= $this->formFile('avatar',array('class'=>'floatLeft' ));
	if($this->arrParam['action'] == 'edit'){
		$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
				'fileConfig'=>'patient-testimonial.ini'));
		// Start - Lấy hình ảnh của avatar
		$pictureConfig = $config->getConfig('patient');
		$current_picture = '<div id="load-content-avatar" class="clr width-150 center">';
		if(!empty($this->Item['avatar'])){
			$pictureUrl = $pictureConfig['thumbUrl'] . '/' . $this->Item['avatar'];
			$removeLink = $this->url(array('action'=>'remove-pic','type'=>'avatar','file'=>$this->Item['avatar']));
			$current_picture .= '<br>' . $this->cmsImage('avatar',$pictureUrl,array('width'=>'175px'))
			. '<br><a  class="remove" href="javascript:loadPage(\'div#load-content-avatar\',\'' . $removeLink . '\')">remove</a>';
		}
		$current_picture .= $this->formHidden('current_avatar',$this->Item['avatar'])
		. '</div>';
		$picture .=	$current_picture;
	}
	
	$arrTooltip = array(
						'name'=>"Tiêu đề bài viết.",
						'status'=>'Trạng thái bài viết',
						'd_content'=>"Nội dung bài viết",
						);
						
	if(count($arrTooltip)>0){
		foreach ($arrTooltip as $key => $val){
		   if($key=='d_content') $attribs = array('leftOffset'=>-305);
		   $formHelp  .= $this->cmsFormHelp('.form-table #' . $key, $this->translate($val), $attribs); 
		}
	}
	
	 if(count($this->errors)>0){	
	 	foreach ($this->errors as $key => $val){	 		
	 		$$key .= $this->cmsError($key,$val);	
	 		$selector = '.form-table #' . $key . '-error';
	 		$options = array('type'=>'error','name'=>'#' .$key);
	 		$formHelp  .= $this->cmsFormHelp($selector, $this->translate($val),null,$options);
	 		
	 	}
	 }
	 $arrRow = array(
					array('label'=>$this->translate('Họ và tên'),'input'=>$name),	
					array('label'=>$this->translate('Ảnh đại diện'),'input'=>$picture),	
					array('label'=>$this->translate('Điện thoại'),'input'=>$phone),	
					array('label'=>$this->translate('Email'),'input'=>$email),	
					array('label'=>$this->translate('Nội Dung'),'input'=>$content),
					array('label'=>$this->translate('Trạng Thái'),'input'=>$status),
					);
	$tdForm = $this->partialLoop('row.php',$arrRow);
	
?>
<script type="text/javascript">
	$(document).ready(function() {
		<?php echo $formHelp;?>
	});
</script>
<div id="element-box">
	<div class="m">
		<div class="form-table">
        	<fieldset class="admin-fieldset">
                <legend class="admin-legend"><?php echo $this->translate('Form detail')?></legend>
            	<table width="100%" border="0">
                	<?php echo $tdForm;?>
                </table>
                <div class="clr"></div>
        	</fieldset>  
        </div>
       
        <div class="clr"></div>
	</div>
</div>
